# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=android-apktool
_pkgname=Apktool
pkgver=2.7.0
pkgrel=1
pkgdesc='A tool for reverse engineering Android apk files.'
arch=('x86_64' 'aarch64')
groups=('blackarch' 'blackarch-reversing' 'blackarch-disassembler')
url='https://github.com/iBotPeaches/Apktool/releases'
license=('Apache')
depends=('jdk17-openjdk') # java-environment, doesn't work with Java 19
makedepends=('git')
source=("$pkgname-$pkgver.tar.gz::https://github.com/iBotPeaches/$_pkgname/archive/v$pkgver.tar.gz"
        'apktool')
sha512sums=('97786fdb85c48c7d344775102e92de417ab5dbb908712d0230fce90a4c76c8a42d2df7f2f8d07f8589c42454cb1207dca1da87a048339fc143c1b0694c397877'
            'aa30257ea9bb6102893edab8f5926c7a4abbe94601e7b7e6273ddf89150969f99d27601a83d0e17a6163c3d5822df3479f9c1e84ab0e8bf6018e1e076fc275d4')

prepare() {
  sed -i 's|libdir=.*progdir|libdir="/usr/share/android-apktool|' apktool
}

build() {
  cd "$_pkgname-$pkgver"

  ./gradlew build shadowJar
}

package() {
  cd "$_pkgname-$pkgver"

  install -Dm 755 "$srcdir/apktool" "$pkgdir/usr/bin/apktool"
  install -Dm 755 brut.apktool/apktool-cli/build/libs/apktool-cli-all.jar \
    "$pkgdir/usr/share/$pkgname/apktool.jar"
}

